declare i32 @printf(i8* , ...)
declare i8* @strcat(i8* , i8* )
declare i32 @strlen(i8*)
declare double @llvm.pow.f64(double, double)
declare double @atof(i8*)
declare i32 @sprintf(i8*, i8*, ...)
declare i8* @malloc(i32)
declare void @llvm.memset.i32(i8* , i8, i32, i32)
declare i8* @strcpy(i8* , i8*)
declare i32 @strcmp(i8*, i8*)
@ftoa.str = internal constant [3 x i8] c"%f\00"
@false.str = internal constant [6 x i8] c"false\00"
@true.str = internal constant [5 x i8] c"true\00"
@global.c = common global i8* null
@global.d = common global i8* null
@global.e = common global double 0.000000e+00
@ccat.retval = common global {i8*, i8*} zeroinitializer
@string0 = constant [7 x i8] c"Cellar\00"
@string1 = constant [5 x i8] c"Door\00"
@string2 = constant [40 x i8] c"***************************************\00"
@print0 = constant [5 x i8] c"%s\09\0A\00"
@string3 = constant [11 x i8] c"These are \00"
@string4 = constant [8 x i8] c"strings\00"
@print1 = constant [5 x i8] c"%s\09\0A\00"
@string5 = constant [6 x i8] c" Door\00"
@print2 = constant [5 x i8] c"%s\09\0A\00"
@string6 = constant [7 x i8] c"Cellar\00"
@string7 = constant [2 x i8] c" \00"
@print3 = constant [5 x i8] c"%s\09\0A\00"
@string8 = constant [40 x i8] c"***************************************\00"
@print4 = constant [5 x i8] c"%s\09\0A\00"
@string9 = constant [20 x i8] c"These are integers\0A\00"
@print5 = constant [8 x i8] c"%s\09%f\09\0A\00"
@print6 = constant [5 x i8] c"%f\09\0A\00"
@string10 = constant [40 x i8] c"***************************************\00"
@print7 = constant [5 x i8] c"%s\09\0A\00"
@string11 = constant [18 x i8] c"These are Boolean\00"
@print8 = constant [5 x i8] c"%s\09\0A\00"
@print9 = constant [5 x i8] c"%s\09\0A\00"
@print10 = constant [5 x i8] c"%s\09\0A\00"
@string12 = constant [40 x i8] c"***************************************\00"
@print11 = constant [5 x i8] c"%s\09\0A\00"
define void @ccat(i8* %a, i8* %b) alwaysinline {
entry:
%ccat.a = alloca i8*
store i8* %a, i8** %ccat.a
%ccat.b = alloca i8*
store i8* %b, i8** %ccat.b
%retval0 = alloca i8*
%retval1 = alloca i8*
br label %ccat.bb1
ccat.bb1:
%ccat.bb1.tmp0 = load i8** %ccat.a
%ccat.bb1.tmp1 = load i8** %ccat.b
store i8* %ccat.bb1.tmp0, i8** %retval0
store i8* %ccat.bb1.tmp1, i8** %retval1
br label %return
return:
%ccat.return.tmp2 = load i8** %retval0
%ccat.return.tmp3 = getelementptr {i8*, i8*}* @ccat.retval, i32 0, i32 0
store i8* %ccat.return.tmp2, i8** %ccat.return.tmp3
%ccat.return.tmp4 = load i8** %retval1
%ccat.return.tmp5 = getelementptr {i8*, i8*}* @ccat.retval, i32 0, i32 1
store i8* %ccat.return.tmp4, i8** %ccat.return.tmp5
ret void
}
define i32 @main() alwaysinline {
entry:
br label %main.bb0
main.bb0:
%main.bb0.tmp6 = bitcast [7 x i8]* @string0 to i8*
%main.bb0.tmp7 = bitcast [5 x i8]* @string1 to i8*
call void@ccat(i8* %main.bb0.tmp6, i8* %main.bb0.tmp7)
%main.bb0.tmp8 = load {i8*, i8*}* @ccat.retval
%main.bb0.tmp9 = extractvalue {i8*, i8*} %main.bb0.tmp8, 0
%main.bb0.tmp10 = extractvalue {i8*, i8*} %main.bb0.tmp8, 1
%main.bb0.tmp11 = load i8** @global.c
%main.bb0.tmp12 = load i8** @global.d
store i8* %main.bb0.tmp9, i8** @global.c
store i8* %main.bb0.tmp10, i8** @global.d
%main.bb0.tmp14 = add double 0.000000e+00, 10.000000
%main.bb0.tmp15 = add double 0.000000e+00, 10.000000
%main.bb0.tmp13 = mul double %main.bb0.tmp14, %main.bb0.tmp15
%main.bb0.tmp16 = load double* @global.e
store double %main.bb0.tmp13, double* @global.e
%main.bb0.tmp17 = bitcast [40 x i8]* @string2 to i8*
%main.bb0.tmp18 = bitcast [5 x i8]* @print0 to i8*
call i32 (i8*, ...)* @printf(i8* %main.bb0.tmp18, i8* %main.bb0.tmp17)
%main.bb0.tmp20 = bitcast [11 x i8]* @string3 to i8*
%main.bb0.tmp21 = bitcast [8 x i8]* @string4 to i8*
%main.bb0.tmp22 = call i8*@stringcat(i8* %main.bb0.tmp20, i8* %main.bb0.tmp21)
%main.bb0.tmp23 = bitcast [5 x i8]* @print1 to i8*
call i32 (i8*, ...)* @printf(i8* %main.bb0.tmp23, i8* %main.bb0.tmp22)
%main.bb0.tmp25 = load i8** @global.c
%main.bb0.tmp26 = bitcast [6 x i8]* @string5 to i8*
%main.bb0.tmp27 = call i8*@stringcat(i8* %main.bb0.tmp25, i8* %main.bb0.tmp26)
%main.bb0.tmp28 = bitcast [5 x i8]* @print2 to i8*
call i32 (i8*, ...)* @printf(i8* %main.bb0.tmp28, i8* %main.bb0.tmp27)
%main.bb0.tmp30 = bitcast [7 x i8]* @string6 to i8*
%main.bb0.tmp32 = bitcast [2 x i8]* @string7 to i8*
%main.bb0.tmp33 = load i8** @global.d
%main.bb0.tmp34 = call i8*@stringcat(i8* %main.bb0.tmp32, i8* %main.bb0.tmp33)
%main.bb0.tmp35 = call i8*@stringcat(i8* %main.bb0.tmp30, i8* %main.bb0.tmp34)
%main.bb0.tmp36 = bitcast [5 x i8]* @print3 to i8*
call i32 (i8*, ...)* @printf(i8* %main.bb0.tmp36, i8* %main.bb0.tmp35)
%main.bb0.tmp37 = bitcast [40 x i8]* @string8 to i8*
%main.bb0.tmp38 = bitcast [5 x i8]* @print4 to i8*
call i32 (i8*, ...)* @printf(i8* %main.bb0.tmp38, i8* %main.bb0.tmp37)
%main.bb0.tmp39 = bitcast [20 x i8]* @string9 to i8*
%main.bb0.tmp40 = load double* @global.e
%main.bb0.tmp41 = bitcast [8 x i8]* @print5 to i8*
call i32 (i8*, ...)* @printf(i8* %main.bb0.tmp41, i8* %main.bb0.tmp39, double %main.bb0.tmp40)
%main.bb0.tmp42 = add double 0.000000e+00, 10.000000
%main.bb0.tmp43 = bitcast [5 x i8]* @print6 to i8*
call i32 (i8*, ...)* @printf(i8* %main.bb0.tmp43, double %main.bb0.tmp42)
%main.bb0.tmp44 = bitcast [40 x i8]* @string10 to i8*
%main.bb0.tmp45 = bitcast [5 x i8]* @print7 to i8*
call i32 (i8*, ...)* @printf(i8* %main.bb0.tmp45, i8* %main.bb0.tmp44)
%main.bb0.tmp46 = bitcast [18 x i8]* @string11 to i8*
%main.bb0.tmp47 = bitcast [5 x i8]* @print8 to i8*
call i32 (i8*, ...)* @printf(i8* %main.bb0.tmp47, i8* %main.bb0.tmp46)
%main.bb0.tmp49 = add i1 0, 1
%main.bb0.tmp48 = sub i1 1, %main.bb0.tmp49
%main.bb0.tmp50 = call i8*@btoa(i1 %main.bb0.tmp48)
%main.bb0.tmp51 = bitcast [5 x i8]* @print9 to i8*
call i32 (i8*, ...)* @printf(i8* %main.bb0.tmp51, i8* %main.bb0.tmp50)
%main.bb0.tmp53 = add i1 0, 0
%main.bb0.tmp52 = sub i1 1, %main.bb0.tmp53
%main.bb0.tmp54 = call i8*@btoa(i1 %main.bb0.tmp52)
%main.bb0.tmp55 = bitcast [5 x i8]* @print10 to i8*
call i32 (i8*, ...)* @printf(i8* %main.bb0.tmp55, i8* %main.bb0.tmp54)
%main.bb0.tmp56 = bitcast [40 x i8]* @string12 to i8*
%main.bb0.tmp57 = bitcast [5 x i8]* @print11 to i8*
call i32 (i8*, ...)* @printf(i8* %main.bb0.tmp57, i8* %main.bb0.tmp56)
ret i32 0
}
define i8* @ftoa(double %num) alwaysinline {
entry:
%0 = tail call i8* @malloc(i32 256)
tail call void @llvm.memset.i32(i8* %0, i8 0, i32 256, i32 1)
%1 = tail call i32 (i8*, i8*, ...)* @sprintf(i8* %0, i8* getelementptr ([3 x i8]* @ftoa.str, i32 0, i32 0), double %num)
ret i8* %0
}
define i8* @stringcat(i8* %s1, i8* %s2) alwaysinline {
entry:
%0 = tail call i8* @malloc(i32 256)
tail call void @llvm.memset.i32(i8* %0, i8 0, i32 256, i32 1)
%1 = tail call i8* @strcpy(i8* %0, i8* %s1)
%2 = tail call i8* @strcat(i8* %0, i8* %s2)
ret i8* %0
}
define i1 @stringcmp(i8* %s1, i8* %s2, i32 %op) alwaysinline {
entry:
%0 = tail call i32 @strcmp(i8* %s1, i8* %s2)
	switch i32 %op, label %return [
i32 0, label %bb
i32 1, label %bb1
i32 2, label %bb2
i32 3, label %bb3
i32 4, label %bb4
i32 5, label %bb5
]
bb:
%1 = icmp slt i32 %0, 0
ret i1 %1
bb1:
%2 = icmp sgt i32 %0, 0
ret i1 %2
bb2:
%3 = icmp slt i32 %0, 1
ret i1 %3
bb3:
%4 = icmp sgt i32 %0, -1
ret i1 %4
bb4:
%5 = icmp ne i32 %0, 0	
ret i1 %5
bb5:
%6 = icmp eq i32 %0, 0	
ret i1 %6
return:
ret i1 undef
}
define i8* @btoa(i1 %i) alwaysinline {
entry:
        %.0 = select i1 %i, i8* getelementptr ([5 x i8]* @true.str, i32 0, i32 0), i8* getelementptr ([6 x i8]* @false.str, i32 0, i32 0)
ret i8* %.0
}
